package OSMS.action.Boss;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import OSMS.dao.GoodsDao;
import OSMS.entity.*;


public class OrderListServlet extends HttpServlet{

	private GoodsDao dao = new GoodsDao();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			
			//最终确定是通过session获取当前登录商家的bid才有效
			HttpSession session = request.getSession();
			Object obj_user = session.getAttribute("boss");//从LoginServlet中获取user值
			Boss boss = (Boss) obj_user;
			String bid = null;
			Object id = boss.getBid();
			bid = id.toString();		
			
			
			// 调用dao的方法查询商家旗下的商品数据
			List<Order> orderList = dao.searchOrderByBid(bid);
			// 将OrederList数据装入域对象中。
			request.setAttribute("orderList", orderList);
			// 跳转到orderlist.jsp页面以展示旗下商品信息
			request.getRequestDispatcher("orderlist.jsp").forward(request, response);
		} catch(Exception ex) {
			ex.printStackTrace();
		}
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}
	
	

}